﻿using System;
using System.Collections.Generic;
using System.Net;
using System.Text;

namespace HttpFileServer
{
    public class ClientIPGeter
    {
        private static int index = 0;
        public static string GetLocalIp()
        {
            ///获取本地的IP地址
            var AddressIP = string.Empty;
            var addressList = new List<IPAddress>( Dns.GetHostEntry(Dns.GetHostName()).AddressList)
                .FindAll(ip=> ip.AddressFamily.ToString() == "InterNetwork");
            if (addressList.Count == 0) return "127.0.0.1";
            return addressList[(++index) % addressList.Count].ToString();
        }
    }
}
